<?php

/*
|--------------------------------------------------------------------------
| Web Routes
|--------------------------------------------------------------------------
|
| Here is where you can register web routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| contains the "web" middleware group. Now create something great!
|
*/

Route::get('/404', 'ErrorController@__404')->name('404');
Route::get('/503', 'ErrorController@__503')->name('503');

Route::get('/callback', 'CallbackController');
Route::any('/callback/alipay', 'CallbackController@aliPay');

Auth::routes();

Route::group(['middleware'=>['auth']], function(){
    Route::get('/', 'IndexController@index')->name('/');

    Route::get('/order/all', 'OrderController@all');
    Route::get('/order/arbitratelist', 'OrderController@arbitrateList');
    Route::get('/order/complainlist', 'OrderController@complainList');
    Route::get('/order/show/{order}', 'OrderController@show');
    Route::get('/order/showoffer/{order}', 'OrderController@showOffer');
    Route::get('/order/showstatus/{order}', 'OrderController@showStatus');
    Route::get('/order/showrefund/{order}', 'OrderController@showRefund');
    Route::any('/order/showarbitrate/{order}', 'OrderController@showArbitrate');
    Route::any('/order/showcomplain/{order}', 'OrderController@showComplain');

    Route::get('/merchant/all', 'MerchantController@all');
    Route::get('/merchant/enable/{merchant_id}', 'MerchantController@enable');
    Route::get('/merchant/disable/{merchant_id}', 'MerchantController@disable');
    Route::get('/merchant/coupon/{merchant_id}', 'MerchantController@coupon');
    Route::get('/merchant/goods/{merchant_id}', 'MerchantController@goods');
    Route::get('/merchant/delgoods/{goods}', 'MerchantController@delGoods');
    Route::get('/merchant/applypriced', 'MerchantController@applyPriced');

    Route::get('/master/all', 'MasterController@all');
    Route::get('/master/registerpass/{master_id}', 'MasterController@registerPass');
    Route::get('/master/headimgpass/{master_id}', 'MasterController@headimgPass');
    Route::get('/master/enable/{master_id}', 'MasterController@enable');
    Route::post('/master/disable', 'MasterController@disable');
    Route::get('/master/delmaster/{master_id}', 'MasterController@delMaster');

    Route::get('/finance/merchanttrade', 'FinanceController@merchantTrade');
    Route::get('/finance/mastertrade', 'FinanceController@masterTrade');
    Route::get('/finance/masterfundtrade', 'FinanceController@masterFundTrade');
    Route::get('/finance/masterfundtradereturning', 'FinanceController@masterFundTradeReturning');
    Route::get('/finance/masterfundtradereturned', 'FinanceController@masterFundTradeReturned');
    Route::get('/finance/mastercash', 'FinanceController@masterCash');
    Route::get('/finance/mastercashed', 'FinanceController@masterCashed');
    Route::get('/finance/mastercashrefuse', 'FinanceController@masterCashRefuse');
    Route::any('/finance/cash/agree/{cash_id?}', 'FinanceController@cashAgree');
    Route::get('/finance/cash/disagree/{cash}', 'FinanceController@cashDisagree');
    Route::any('/finance/returnfund/agree/{fund_id?}', 'FinanceController@returnFundAgree');
    Route::get('/finance/returnfund/disagree/{fund}', 'FinanceController@returnFundDisagree');
    Route::get('/finance/systemwallethistory', 'FinanceController@systemWalletHistory');

    Route::get('/admin/managerlist', 'AdminController@managerList');
    Route::get('/admin/enable/{manager_id}', 'AdminController@enable');
    Route::get('/admin/disable/{manager_id}', 'AdminController@disable');
    Route::get('/admin/delete/{manager_id}', 'AdminController@delete');
    Route::post('/admin/edit', 'AdminController@edit');
    Route::post('/admin/editpass', 'AdminController@editPass');
    Route::post('/admin/add', 'AdminController@add');
    Route::get('/admin/smsloglist', 'AdminController@smsLogList');
    Route::get('/admin/arealist', 'AdminController@areaList');
    Route::post('/admin/areaadd', 'AdminController@areaAdd');
    Route::post('/admin/areaedit', 'AdminController@areaEdit');
    Route::get('/admin/areadel/{province}', 'AdminController@areaDel');
    Route::get('/admin/alipayloglist', 'AdminController@alipayLogList');
    Route::get('/admin/notifyloglist', 'AdminController@notifyLogList');

    Route::get('/article/all', 'ArticleController@all');
    Route::any('/article/add', 'ArticleController@add');
    Route::any('/article/edit/{article}', 'ArticleController@edit');
    Route::get('/article/delete/{article}', 'ArticleController@delete');
    Route::get('/article/show/{article}', 'ArticleController@show');
    Route::get('/article/bannerlist', 'ArticleController@bannerList');
    Route::any('/article/banneradd', 'ArticleController@bannerAdd');
    Route::any('/article/banneredit/{banner}', 'ArticleController@bannerEdit');
    Route::get('/article/bannerdelete/{banner}', 'ArticleController@bannerDelete');

    Route::any('/coupon/create', 'CouponController@create');
    Route::any('/coupon/edit/{coupon}', 'CouponController@edit');
    Route::get('/coupon/all', 'CouponController@all');
    Route::get('/coupon/receive', 'CouponController@receive');
    Route::get('/coupon/delgrant/{coupon}', 'CouponController@delGrant');
    Route::post('/coupon/assign', 'CouponController@assign');
});

Route::group(['namespace'=>'Ajax','prefix' => 'ajax'], function(){
    Route::get('/merchant/detail/{merchant}', 'MerchantController@detail');
    Route::get('/master/detail/{master}', 'MasterController@detail');
    Route::get('/master/wallet/{master}', 'MasterController@wallet');
});

/**
 * 静态资源请求
 */
Route::group([], function(){

    Route::get('/css/{path}', function($path){
        try{
            return response()->file(public_path('css'.DIRECTORY_SEPARATOR.$path),['Content-Type'=>'text/css']);
        }catch(Exception $e){
            return 'file miss';
        }
    })->where('path', '[\w\.\/-]+');

    Route::get('/js/{path}', function($path){
        try{
            return response()->file(public_path('js'.DIRECTORY_SEPARATOR.$path),['Content-Type'=>'application/x-javascript']);
        }catch(Exception $e){
            return 'file miss';
        }
    })->where('path', '[\w\.\/-]+');

    Route::get('/images/{path}', function($path){
        $file = public_path('images'.DIRECTORY_SEPARATOR.$path);
        return is_file($file) ? response()->file($file,['Content-Type'=>File::mimeType($file)]) : 'file miss';
    })->where('path', '[\w\.\/-]+');

    Route::get('/upload/{path}', 'UploadController@get')->where('path', '.+')->name('uploaded');

});

Route::any('/test', 'TestController@index');
Route::any('/phpinfo', 'TestController@phpinfo');
Route::get('/demo', 'DemoController@index');
Route::get('/demo/form', 'DemoController@form');
Route::get('/demo/table', 'DemoController@table');
Route::get('/demo/button', 'DemoController@button');
Route::any('/mock/addorder', 'MockController@addOrder');
Route::any('/mock/all', 'MockController@all');
Route::any('/mock/offer/{order}', 'MockController@offer');
Route::any('/mock/employ/{order_id}/{master_id}', 'MockController@employOrder');
Route::any('/mock/refund/{order_id}', 'MockController@refundOrder');
Route::any('/mock/arbitrate/{order_id}', 'MockController@arbitrateOrder');
Route::any('/mock/transfer/{order_id}', 'MockController@transferOrder');
Route::any('/mock/evaluate/{order_id}', 'MockController@evaluateOrder');
Route::any('/mock/complain/{order_id}', 'MockController@complainOrder');